home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1999 March
/
EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso
/
earcd
/
devel
/
vbcc-68k-src
/
machines
/
amiga68k
/
libsrc
/
stdio
/
_putbuf.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-01
|
782b
|
30 lines
#include <stdlib.h>
#include <stdio.h>
#include <proto/dos.h>
/* schreibt Daten aus Buffer */
/* fuegt c als neues Zeichen ein, falls c!=EOF */
int _putbuf(int c,FILE *f)
{
_chkabort();
if(!f) return(EOF);
if((f->flags&(_WRITEABLE|_READ|_EOF|_ERR))!=_WRITEABLE) return(EOF);
if(!f->bufsize){if(f->flags&_UNBUF) f->bufsize=1; else f->bufsize=BUFSIZ;}
if(!f->base){
if(!(f->base=(char *)malloc(f->bufsize+1)+1))
return(EOF);
}else{
int len=f->pointer-f->base;
if(Write((BPTR)f->filehandle,f->base,len)!=len){
f->flags|=_ERR;
return(EOF);
}
}
f->flags|=_WRITE;
*f->base=c;
f->pointer=f->base+1;
f->count=f->bufsize-1;
return(0); /* hier noch ueberlegen */
}